package com.zh.user.controller;

import com.zh.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @Description:
 * @ClassName TestRedisController
 * @date: 2021.04.21 10:51
 * @Author: zhanghang
 */
@RestController
public class TestRedisController {

    @Autowired
    private RedisUtil redisUtil;

    @GetMapping("/addRedis")
    public String addRedis(){
        redisUtil.set("zhangsi","123456");
        redisUtil.expire("zhangsi", 5);
        return "ok";
    }

    @GetMapping("/addRedis1")
    public String addRedis1(){
        redisUtil.set("user:zhangsi","123456");
        redisUtil.expire("user:zhangsi", 20);
        return "ok";
    }

    @GetMapping("/addRedis2")
    public String addRedis2(){
        redisUtil.hset("huser","hzhangsan","123456");
        return "ok";
    }

    @GetMapping("/deleteRedis1")
    public String deleteRedis1(){
        redisUtil.del("user:zhangsi");
        return "ok";
    }
}
